package com.aorise;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.context.request.async.DeferredResult;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @Auther: zhouhao
 * @Date: 2019/4/26
 * @Description:
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {
    @Value("${swagger.enable}")
    private boolean enableSwagger;
    @Bean
    public Docket RecruitApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("Recruit")
                .genericModelSubstitutes(DeferredResult.class)
                .useDefaultResponseMessages(false)
                .forCodeGeneration(true)
                .pathMapping("")//默认访问根目录
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.aorise.controller"))
                .build()
                .enable(enableSwagger)
                .apiInfo(RecruitApinfo());

    }


    private ApiInfo RecruitApinfo() {
        return new ApiInfoBuilder()
                .title("Api for video-system SaaS Server")
                .description("video-system Server's REST API")
                .version("V1.0")
                .termsOfServiceUrl("NO terms of service")
                .contact(new Contact("", "", ""))
                .license("GPL")
                .licenseUrl("")
                .build();
    }
}
